<template>
  <div class="body">
    <!-- 头部 -->
    <van-nav-bar title="钻石商城" left-arrow @click-left="onClickLeft" />

    <!-- 内容 -->
    <div class="main">
      <div class="nav">
        <span>我的钻石</span>
        <i><img src="./../assets/image/zuanshi.png" alt="" /> {{ money }} </i>
        <em>兑换记录</em>
      </div>
      <!-- 格子 -->
      <ul class="GongGe">
        <li v-for="item in list" :key="item.id">
          <p><img :src="item.src" alt="" /></p>
          <div class="text-G">
            <p>
              <em>{{ item.title }}</em>
            </p>
            <p>
              <span>已售{{ item.sellNum }}</span>
              <em
                ><img src="./../assets/image/zuanshi.png" alt="" />
                {{ item.price }}</em
              >
            </p>
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import { ref, onMounted } from "vue";
import { getClassListApi, getMyInfoApi } from "../utils/api";
export default {
  setup() {
    const list = ref([]);
    const cout = ref(5);
    const token = localStorage.getItem("token");
    const money = ref();
    onMounted(async () => {
      const res = await getClassListApi();
      console.log(res);
      if (res.status === 0) {
        list.value = res.classList;
        console.log(list.value);
      }
      const res1 = await getMyInfoApi({ token });
      money.value = res1.results.myMoney;
      // console.log(res1);
      console.log(money);
      // console.log("Component is mounted!");
    });

    return { cout, list, money };
  },
  methods:{
    onClickLeft(){
      this.$router.go("-1")
    }
  }
};
</script>

<style lang="less" scoped>
/deep/.van-ellipsis {
  font-size: 18px;
  font-weight: 700;
}
// .body{
//   width:220px;
// }
.main {
  width: 95%;
  margin: auto;
  //background: rgb(51, 156, 255);
  .GongGe {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    li {
      margin-bottom: 20px;
      box-shadow: 0 0 8px 1px rgb(211, 211, 211);
      width: 48%;
      background: #e6e6e6;
      p > img {
        width: 100%;
      }
      .text-G {
        height: 70px;
        //background: blue;
        display: flex;
        flex-direction: column;
        padding: 10px;
        justify-content: space-between;
      }
      p {
        display: flex;
        justify-content: space-between;
        font-size: 15px;
        em {
          font-weight: 800;
          img {
            width: 14px;
          }
        }
      }
    }
  }
}
.nav {
  height: 60px;
  display: flex;
  font-size: 16px;
  line-height: 70px;
  img {
    width: 14px;
  }
  span,
  i {
    font-weight: 700;
  }
  i {
    padding-left: 20px;
    flex: 3;
  }
}
</style>
